//
//  ASResearchLevelVC.m
//  AttendenceSys
//
//  Created by 窦芳俊 on 16/4/13.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "ASResearchLevelVC.h"

#define kResearchLevelCellHeight  50

@interface ASResearchLevelVC () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *rLevelTableView;
@property (nonatomic, strong) NSArray *researchArray;

@end

@implementation ASResearchLevelVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _researchArray = @[@"国家级", @"省部级", @"校级", @"院级"];
    
    self.strNavTitle = @"科研级别";
    self.view.backgroundColor = [UIColor whiteColor];
    
    _rLevelTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _rLevelTableView.frame = CGRectMake(0, 0, self.view.frame.size.width, 200);
    _rLevelTableView.delegate = self;
    _rLevelTableView.dataSource = self;
    _rLevelTableView.backgroundColor = [UIColor whiteColor];
    _rLevelTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    _rLevelTableView.rowHeight = kResearchLevelCellHeight;
    [self.view addSubview:_rLevelTableView];
    
    [_rLevelTableView reloadData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_researchArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"researchLevelTableViewCellIdentifier"];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] init];
    }
    
    cell.textLabel.text = [_researchArray objectAtIndex:[indexPath row]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(selectResearchLevel:)])
    {
        [self.delegate selectResearchLevel:[_researchArray objectAtIndex:[indexPath row]]];
    }
}


@end
